



use "${pathdata_mechanism}/MechanismExperiment2.dta", clear



preserve





* ### Belief Movement: Main Table ###	
		
bysort prolific_pid : drop if _N == 1

keep if product == "foodtruck"
		
	* Step 1: Clone the dataset
gen _clone = 1

* Step 2: Replace the values
* For the cloned dataset
replace effect = abs_belief * 100 if _clone == 1
replace effect_recall = abs_belief * 100 if _clone == 1
replace treatment = "bayesian_movement_control" if _clone == 1 & treatment == "control"
replace treatment = "bayesian_movement_treatment" if _clone == 1 & treatment == "treatment"

duplicates drop


* Step 3: Append the cloned dataset to the original one
append using "${pathdata_mechanism}/MechanismExperiment2.dta", gen(_source)

keep if product == "foodtruck"



	gen temp_group = 0 if treatment == "control"
	replace temp_group = 1 if treatment == "treatment"
	replace temp_group = 2 if inlist(treatment, "bayesian_movement_control", "bayesian_movement_treatment")
	bysort prolific_pid : drop if _N==1


collapse (mean) effect effect_recall (sem) imm_sem = effect del_sem = effect_recall, by(temp_group)	 
	rename imm_sem sem0
	rename del_sem sem1
	rename effect dev0
	rename effect_recall dev1
	reshape long sem dev, i(temp_group) j(delay)
	gen upper=dev+sem
	gen lower=dev-sem
	
	


	tw (scatter dev delay if temp_group == 0, connect(l) lcolor(black*0.5) lpattern(solid)  msize(large) ms(d) mcolor(black*0.5)) ///
		(scatter dev delay if temp_group == 1, connect(l) lcolor(black*1.5) lpattern(shortdash)   msize(large) ms(o) mcolor(black*1.5)) ///
			(scatter dev delay if temp_group == 2, connect(l) lpattern(dash_dot) msize(0.000001) ms(d) lcolor(black*1.5) mcolor(black*1.5)) ///
		(rcap upper lower delay if temp_group == 0, lw(medthick) lcolor(black*0.5))	///
		(rcap upper lower delay if temp_group == 1, lw(medthick) lcolor(black*1.5)),	///
	ytitle("Mean belief impact {c 177} SEM" "(percentage points)") ///
		xtitle(" ") xsc(r(-0.5 1.5) lcolor(none)) ysc(r(0 20) lcolor(none)) ///
		yline(0, lcolor(gs10) lwidth(thin)) ///
		graphregion(color(white)) title("Belief impact in {it:Immediate} and {it:Delay}",  margin(b=3) color(black)) ///
		legend(order(1 2 3) label(1 "Low Interference") label(2 "High Interference") label(3 "Bayesian Benchmark") r(1)) ///
		xlabel(0 "Immediate" 1 "1-day delay") ysize(5) xsize(10)
	graph export "${pathout_mechanism}/figures/figure5a.pdf", replace
			

restore







preserve





* ### RECALL GRAPH ###

keep if product == "foodtruck"

egen overall_stddev = sd(correct_recall)
display "Overall standard deviation of correct_recall: " overall_stddev

collapse (mean) correct_recall (sem) stderr = correct_recall, by (treatment)
tabstat correct_recall stderr, by(treatment) stat(mean sem)



rename correct_recall  dev
gen upper = dev + stderr
gen lower = dev - stderr


egen treatment_num = group(treatment)

tw (scatter dev treatment_num if treatment == "control", connect(l) mcolor(black*0.5) msize(large) ms(d)) ///
   (scatter dev treatment_num if treatment =="treatment" , connect(l) mcolor(black*1.5) msize(large) ms(o)) ///
   (rcap upper lower treatment_num if treatment == "control", lw(medthick) lcolor(black*0.5)) ///
   (rcap upper lower treatment_num if treatment == "treatment", lw(medthick) lcolor(black*1.5)) ///
   , ytitle("Mean Rate  {c 177} SEM") ///
   xtitle(" ") xsc(r(0.5 2.5) lcolor(none)) ysc(r(0 0.6) lcolor(none)) ///
   yline(0, lcolor(gs10) lwidth(thin)) ///
   graphregion(color(white)) title("Correct recall of information and valence", color(black)) ysize(5) xsize(10) ///
   ylabel(0(0.2)0.6, tlc(none) angle(0) glcolor(gs15) glwidth(thin)) ///
   legend(off) ///
   xlabel(1 "Low Interference" 2 "High Interference", valuelabel)
   
drop treatment_num
graph export "${pathout_mechanism}/figures/figure5b.pdf", replace
